layui.use(['table', 'jquery'], function () {
    const table = layui.table,
        $ = layui.jquery;

    //默认加载时执行
    findAll();

    function findAll() {

        let code = $('#code').val();
        let value = $('#value').val();
        let type = $('#type').val();
        let params = {
            code: code,
            value: value,
            type: type
        };

        let cols = [[
            {type: 'checkbox', fixed: 'left'}
            , {field: 'id', width: 80, title: 'ID', sort: true, fixed: 'left'}
            , {field: 'code', width: '18%', title: '健', sort: true}
            , {field: 'value', width: '18%', title: '值'}
            , {field: 'app', width: '18%', title: '所属App'}
            , {field: 'type', width: '20%', title: '类型', sort: true}
            , {field: 'sequence', width: '15%', title: '排序号', sort: true}
        ]];

        table.render({
            elem: '#dataList'
            , url: LOCAL_CROSS_URL + "/code/findAll"
            , where: params
            , method: 'get'
            , headers: HEADERS
            , request: REQUEST
            , response: RESPONSE
            , cellMinWidth: 80
            , height: 720
            , toolbar: '#toolbar'
            , skin: 'line'
            , even: true
            , page: true
            , limits: [5, 10, 15, 30]
            , limit: 10
            , title: '码表'
            , cols: cols
        });
    }

    /**
     * 查询
     */
    $('#query').on('click', function () {
        findAll()
    });

    /**
     * 重置
     */
    $('#reset').on('click', function () {
        $('#code').val('');
        $('#value').val('');
        $('#type').val('');
    });
});